home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2017 October / PCgo 10-2017 CD-ROM Germany.iso / data / js / app.js next >
Encoding:
JavaScript  |  2016-01-15  |  1.9 KB  |  70 lines

  1.  
  2.     
  3.     $(window).load(function() {
  4.         var contheight = $('.softcontent').height() - 60;
  5.         var navheight  = $('.softnav ul').height();
  6.         if (navheight < contheight) {
  7.             $('.softnav ul').css('height', contheight + 'px');
  8.             $('.softnav ul li:last-child').css('position','absolute');
  9.         }
  10.     });    
  11.     $( 'a.ui-open-file, a.ui-open-dir, a.ui-open-link').off('click').on('click', function ( event ) {
  12.         var fileUrl = $( this ).attr( 'data-im-url' ),
  13.         fileType = $( this ).attr( 'data-im-type' );        
  14.         switch( fileType ) {
  15.             case 'file':
  16.                 openFile(fileUrl);
  17.                 break;
  18.             case 'dir':
  19.                 openFileDir(fileUrl);
  20.                 break;
  21.             case 'link':
  22.                 openLink(fileUrl);
  23.                 break;
  24.         }        
  25.         return false;
  26.     }).css({cursor: 'pointer'});
  27.     
  28.     var base = 'data';
  29.     var gui  = require('nw.gui');
  30.     var win  = gui.Window.get();
  31.     //win.maximize(); 
  32.     
  33.     var path = require('path');
  34.     var fs   = require('fs');           
  35.     
  36.     
  37.     function openFile(file) {        
  38.         var fileInfo = getFilePath(base + file);        
  39.         if( fileInfo.fileExists ) {
  40.             gui.Shell.openItem( fileInfo.filePath );
  41.         }       
  42.     } 
  43.  
  44.     function openFileDir(file) {
  45.         var fileInfo = getFilePath(base + file);        
  46.         if( fileInfo.fileExists ) {
  47.             gui.Shell.showItemInFolder( fileInfo.filePath );
  48.         }
  49.     }
  50.     
  51.     function setFilePath(file) {
  52.         var filePath = path.join( path.dirname(process.execPath), file),
  53.         fileExists   = fs.existsSync( filePath ),
  54.         result = {
  55.             fileExists: fileExists,
  56.             filePath: filePath
  57.         };
  58.         return result;
  59.     } 
  60.     
  61.     function openLink(url) {
  62.         gui.Shell.openExternal( url );
  63.     }
  64.  
  65.     function getFilePath(file) {
  66.         return setFilePath(file);
  67.     }
  68.             
  69.  
  70.